package sevencm.wechat.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import sevencm.wechat.entity.Friend;
import sevencm.wechat.entity.ManifestFiles;
import sevencm.wechat.entity.WechatMM;

import java.util.List;

public interface  ManifestDao {

    @Select("SELECT * FROM Files where domain = #{domain}")
    List<ManifestFiles> getAppData(@Param("domain")String domain);

    @Select("SELECT * FROM Friend ")
    @Results({
            @Result(property="userName", column="userName"),
            @Result(property="type", column="type"),
            @Result(property="certificationFlag", column="certificationFlag"),
            @Result(property="imgStatus", column="imgStatus"),
            @Result(property="extFlag", column="extFlag"),
            @Result(property="openIMAppid", column="openIMAppid"),
            @Result(property="encodeUserName", column="encodeUserName"),
            @Result(property="dbContactLocal", column="dbContactLocal", typeHandler= CustomByteArrayTypeHandler.class),
            @Result(property="dbContactOther", column="dbContactOther", typeHandler= CustomByteArrayTypeHandler.class),
            @Result(property="dbContactRemark", column="dbContactRemark", typeHandler= CustomByteArrayTypeHandler.class),
            @Result(property="dbContactHeadImage", column="dbContactHeadImage", typeHandler= CustomByteArrayTypeHandler.class),
            @Result(property="dbContactProfile", column="dbContactProfile", typeHandler= CustomByteArrayTypeHandler.class),
            @Result(property="dbContactSocial", column="dbContactSocial", typeHandler= CustomByteArrayTypeHandler.class),
            @Result(property="dbContactChatRoom", column="dbContactChatRoom", typeHandler= CustomByteArrayTypeHandler.class),
            @Result(property="dbContactBrand", column="dbContactBrand", typeHandler= CustomByteArrayTypeHandler.class),
            @Result(property="_packed_DBContactTable", column="_packed_DBContactTable", typeHandler= CustomByteArrayTypeHandler.class)
    })
    List<Friend> getDBConnect();

    /**
     * 获取表名
     * @return
     */
    @Select("SELECT name FROM sqlite_master WHERE type='table'")
    List<String> getMessageDBTables();

    /**
     * 获取聊天记录
     * @param table
     * @return
     */
    @Select("SELECT * From ${table}")
    List<WechatMM> getIMData(@Param("table")String table);

}
